﻿using System;
using System.Collections.Generic;
using System.Text;

namespace WxOpenPlatLibCore.Utils
{
    public class DataConvert
    {
        public static int ObjectToInt32(object obj, int defval = 0)
        {
            if (obj == null)
                return defval;
            int retsult = 0;
            if (!Int32.TryParse(obj + "", out retsult))
                retsult = defval;
            return retsult;
        }

        public static long ObjectToLong(object obj, long defval = 0)
        {
            if (obj == null)
                return defval;
            long retsult = 0;
            if (!long.TryParse(obj + "", out retsult))
                retsult = defval;
            return retsult;
        }

        public static decimal ObjectToInt32(object obj, decimal defval = 0)
        {
            if (obj == null)
                return defval;
            decimal retsult = 0;
            if (!decimal.TryParse(obj + "", out retsult))
                retsult = defval;
            return retsult;
        }
    }
}
